import { api } from '@/utils/request'
import type { Schedule, CreateScheduleRequest, UpdateScheduleRequest } from '@/types/schedule'

/**
 * 获取所有日程
 */
export const getSchedules = () => {
  return api.get<Schedule[]>('/schedules')
}

/**
 * 获取单个日程
 */
export const getSchedule = (id: number) => {
  return api.get<Schedule>(`/schedules/${id}`)
}

/**
 * 创建日程
 */
export const createSchedule = (data: CreateScheduleRequest) => {
  return api.post<Schedule>('/schedules', data)
}

/**
 * 更新日程
 */
export const updateSchedule = (id: number, data: UpdateScheduleRequest) => {
  return api.put<Schedule>(`/schedules/${id}`, data)
}

/**
 * 软删除日程
 */
export const deleteSchedule = (id: number) => {
  return api.delete(`/schedules/${id}`)
}

/**
 * 获取已删除的日程（回收站）
 */
export const getDeletedSchedules = () => {
  return api.get<Schedule[]>('/schedules/deleted')
}

/**
 * 恢复日程
 */
export const restoreSchedule = (id: number) => {
  return api.put(`/schedules/${id}/restore`)
}

/**
 * 永久删除日程
 */
export const permanentDeleteSchedule = (id: number) => {
  return api.delete(`/schedules/${id}/permanent`)
}
